package com.qf.model;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    private enum ResultStatus {
        success, failure
    }

    public static Result buildSuccess() {
        return buildSuccess(1, ResultStatus.success.toString(), null);
    }

    public static Result buildSuccess(Object data) {
        return buildSuccess(ResultStatus.success.toString(), data);
    }

    public static Result buildSuccess(String msg, Object data) {
        return buildSuccess(1, msg, data);
    }

    public static Result buildSuccess(Integer code, String msg, Object data) {
        return Result.builder()
                .code(code)
                .msg(msg)
                .data(data)
                .build();
    }

    public static Result buildFailure() {
        return buildFailure(1, ResultStatus.failure.toString(), null);
    }

    public static Result buildFailure(String msg) {
        return buildFailure(msg, null);
    }

    public static Result buildFailure(String msg, Object data) {
        return buildFailure(-1, msg, data);
    }

    public static Result buildFailure(Integer code, String msg, Object data) {
        return Result.builder()
                .code(code)
                .msg(msg)
                .data(data)
                .build();
    }
}
